package com.ace.user.common.http;

import com.ace.user.common.bean.RequestDTO;
import com.ace.user.common.bean.ResponseDTO;
import com.ace.user.common.constant.C;
import com.ace.user.config.locale.RLocale;
import com.ace.user.exception.BusinessException;
import com.alibaba.fastjson.JSONObject;
import feign.FeignException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author: guoyc
 * @Date: 2019/6/11 10:43
 * @Version 1.0
 */
@Component
@Slf4j
public class FeignTokenFailure implements FeignTokenService{

    private final static String SERVER_NAME = "token-server";

    @Resource
    private RLocale rLocale;

    @Override
    public JSONObject addToken(RequestDTO paramDTO) throws FeignException {
        log.error("***** Feign token server error serverName:{}  method:{}  *****",SERVER_NAME,"getToken");
        throw new BusinessException(rLocale.getDTO("COMM_ERR_NET_TIMEOUT", C.T_C_3), rLocale.getMessage("FEIGN_TOKEN_SERVER_ERROR"));
    }
    @Override
    public ResponseDTO testMethod(String uid) throws FeignException {
        log.error("***** Feign token server error serverName:{}  method:{}  *****",SERVER_NAME,"getToken");
        throw new BusinessException(rLocale.getDTO("COMM_ERR_NET_TIMEOUT", C.T_C_3), rLocale.getMessage("FEIGN_TOKEN_SERVER_ERROR"));
    }

    @Override
    public void deleteTokenByUserId(RequestDTO paramDTO) throws FeignException {
        log.error("***** Feign token server error serverName:{}  method:{}  *****",SERVER_NAME,"deleteToken");
        throw new BusinessException(rLocale.getDTO("COMM_ERR_NET_TIMEOUT", C.T_C_3), rLocale.getMessage("FEIGN_TOKEN_SERVER_ERROR"));
    }

    @Override
    public ResponseDTO checkToken( RequestDTO  param) throws FeignException {
        log.error("***** Feign token server error serverName:{}  method:{}  *****",SERVER_NAME,"checkToken");
        throw new BusinessException(rLocale.getDTO("COMM_ERR_NET_TIMEOUT", C.T_C_3), rLocale.getMessage("FEIGN_TOKEN_SERVER_ERROR"));
    }

    @Override
    public String addToken(String uid, String typevalue, RequestDTO paramDTO) throws FeignException {
        log.error("***** Feign token server error serverName:{}  method:{}  *****",SERVER_NAME,"getToken");
        throw new BusinessException(rLocale.getDTO("COMM_ERR_NET_TIMEOUT", C.T_C_3), rLocale.getMessage("FEIGN_TOKEN_SERVER_ERROR"));
    }
}
